package name.panitz.ludens.animationGame;

import javax.swing.*;

import java.awt.Color;
import java.awt.event.*;

public class MenuFrogger extends ControlledWindow {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	TrainFrogger frogger;

	JMenuBar menuBar = new JMenuBar();
	JMenu fileMenu = new JMenu("File");
	JMenu pointsMenu = new JMenu(" Punkte: 0 ");
	JMenu resetMenu = new JMenu(" Resets: 0 ");
	JMenu statusMenu = new JMenu("         ");
	JMenu timeMenu = new JMenu(" Zeit: ");

	MenuFrogger() {
		this(new TrainFrogger());
	}

	MenuFrogger(TrainFrogger tf) {
		super(tf);
		frogger = tf;
		frogger.setMenu(this);

		menuBar.add(fileMenu);

		this.setJMenuBar(menuBar);

		JMenuItem pauseItem = new JMenuItem("Pause");
		fileMenu.add(pauseItem);
		
		pauseItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				p.t.stop();
			}
		});

		fileMenu.add(new JMenuItem(new AbstractAction("Start") {
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e) {
				p.t.start();				
			}
		}));
		
		fileMenu.add(new JMenuItem(new AbstractAction("Neustart") {
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e) {
				frogger.reset();				
			}
		}));

		fileMenu.add(new AbstractAction("Quit") {
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		menuBar.add(pointsMenu, 1);
		menuBar.add(resetMenu, 1);
		menuBar.add(timeMenu, 3);
		menuBar.add(statusMenu, 4);
		pack();
	}

	public void setStatus(int points, int resets, String status) {
		resetMenu.setText(" Resets: " + resets + " ");
		pointsMenu.setText(" Punkte: " + points + " ");
		statusMenu.setText("   " + status + "   ");
		timeMenu.setText("Zeit:  "+frogger.getTime()+"    Zeitbonus:  "+frogger.getBonusPoints());
	}

	public static void main(String[] args) {
		new MenuFrogger();
	}
}
